class Solution {
public:
    bool canJump(vector<int>& nums) {
        if (nums.size() == 1) return true;
        // 覆盖个数
        int cover = 0;
        // 遍历覆盖的个数 取cover的max
        for (int i = 0; i <= cover; i++) {
            if (cover < nums[i] + i) cover = nums[i] + i;
            if (cover >= nums.size() - 1) return true;
        }
        return false;
    }
};
